package com.ina.app.activity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.ina.app.base.BaseActivity;
import com.ina.app.constant.Constant;
import com.ina.app.util.ThreadPool;
import com.ina.app.util.Utils;

/**
 * 登陆界面
 * @author K
 */
public class LoginActivity extends BaseActivity{
	
	private EditText editName; //用户名输入框
	private EditText editPwd;  //密码输入框
	private Button btnSubmit;  //登陆按钮
	private Button btnCancel;  //取消按钮
	private String name;       //获得用户名
	private String password;   //获得密码
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		init();
		btnSubmit.setOnClickListener(listener);
		btnCancel.setOnClickListener(listener);
	}
	
	private void init(){
		setContentView(R.layout.activity_login);
		editName=(EditText) findViewById(R.id.login_edit_name);
		editPwd=(EditText) findViewById(R.id.login_edit_password);
		btnSubmit=(Button) findViewById(R.id.login_btn_submit);
		btnCancel=(Button) findViewById(R.id.login_btn_cancel);
	}
	
	private OnClickListener listener=new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.login_btn_submit:
				name=editName.getText().toString();
				password=editPwd.getText().toString();
				if(!name.equals("") && !password.equals("")){
					startActivitys(LoginActivity.this, MainActivity.class);
					LoginActivity.this.finish();
				}else{
					Utils.Toast(LoginActivity.this, Constant.DICTIONARY[0], 2000);
				}
				break;
			case R.id.login_btn_cancel:
				LoginActivity.this.finish();
				break;
			}
		}
	};
}
